package ua.kpi_java_training.evgeniygusar.module3;

import java.util.Random;
import java.util.HashSet;

public class Obstacle {
    public int x, y;
    int X_BORDER, Y_BORDER;

    Obstacle() {
        Desert mydesert = new Desert();
        X_BORDER = mydesert.getXBorder();
        Y_BORDER = mydesert.getYBorder();
        Create();
    }


    AllObstacles obstaclesObject = new AllObstacles();
    private static Random rndX, rndY;

    /**
     * Creation of new obstacle with uniq x and y coodrinats
     */
    public void Create() {
        rndX=new Random(System.currentTimeMillis());
        rndY=new Random(System.currentTimeMillis()+1);
        do
        {
            x = rndX.nextInt(X_BORDER)+1;
        }
        while (!obstaclesObject.addX(x));

        do
        {
            y = rndY.nextInt(Y_BORDER)+1;
        }
        while (!obstaclesObject.addY(y));
    }

    /**
     * Output of generated coordinats of ostrich
     */
    public void showCoordinats() {
        System.out.println("x = " + x + ", y = " + y);
    }
}
